<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
    .v-enter-active,.v-leave-active{
        transition: all 2s;
    }
    .v-enter-to,.v-leave{
        transform: translateX(80px);
    }
    .v-leave-to,.v-enter{
        transform: translateX(-300px);
    }
    div{
        text-align: center;
    }
</style>
</head>

<body>
    <div id='app'>
        <!-- <login></login>
        <user-info></user-info> -->
        <button @click="flog = !flog">切换</button>
        <transition  mode="out-in">
            <component :is="flog?'login':'user-info'"></component>
        </transition>

    </div>
    <template id="mylogin">
        <div>
            登录
        </div>
    </template>
    <template id="userInfo">
        <div>
            个人信息
        </div>
    </template>

    <script>


        Vue.component("login", {
            template: "#mylogin",
        })
        Vue.component("user-info", {
            template: "#userInfo",
        })



        const vm = new Vue({
            el: '#app',
            data: {
                flog:true
            }
        })
    </script>
</body>

</html>